// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
// import VueRouter from 'vue-router'
import App from './App'
// import Home from './components/HelloFromVux'
import router from './router'
import './fit.less'
import './common.less'
import './normalize.css'
import { cookie } from 'vux'
import { getConfig } from '@/api/home'
import { XHeader, Tab, TabItem, XButton, Group, Cell, Swiper, XSwitch, SwiperItem, XInput, XTable, CellBox, Toast, Scroller, LoadMore, CheckIcon, XDialog, Icon, LoadingPlugin, AlertPlugin, ToastPlugin, DatetimePlugin } from 'vux'
Vue.component('x-header', XHeader)
Vue.component('tab', Tab)
Vue.component('tab-item', TabItem)
Vue.component('x-button', XButton)
Vue.component('group', Group)
Vue.component('cell', Cell)
Vue.component('swiper', Swiper)
Vue.component('swiper-item', SwiperItem)
Vue.component('x-switch', XSwitch)
Vue.component('x-input', XInput)
Vue.component('x-table', XTable)
Vue.component('cell-box', CellBox)
Vue.component('toast', Toast )
Vue.component('scroller', Scroller)
Vue.component('load-more', LoadMore)
Vue.component('check-icon', CheckIcon)
Vue.component('x-dialog', XDialog)
Vue.component('icon', Icon)

Vue.use(LoadingPlugin)
Vue.use(DatetimePlugin)
Vue.use(AlertPlugin)
Vue.use(ToastPlugin, { position: 'middle' })

getConfig().then(data => {
  console.log(data)
  sessionStorage.setItem('config', JSON.stringify(data))
})

FastClick.attach(document.body)

Vue.config.productionTip = false
Vue.prototype.globalData = {
  cid: cookie.get('userInfo') && (JSON.parse(cookie.get('userInfo'))).id,
  shareId: window.location.href.indexOf("shareId") !== -1?
    window.location.href.substring(window.location.href.indexOf("shareId") + 8).replace(/(\d+).+/, "$1")
    :''
}

window.document.title = '安数合伙人'

/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')

